package com.example.meitao.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.meitao.R;
import com.example.meitao.bean.Detail;
import com.example.meitao.config.NetConfig;
import com.example.meitao.task.DetailNetTask;
import com.squareup.picasso.Picasso;

/**
 * Created by 星星 on 2016/9/1.
 */
public class GoShopFragment extends Fragment{
    private TextView mTextViewTitle,mTextViewDui,mTextViewNei,mTextViewZan,mTextViewLai,mTextViewTitle2,getmTextViewMoney;
    private ImageView mImageView;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.goshoping_item,null);
        initView(view);
        initData();
        setData();
        setListener();
        return view;
    }

    private void setListener() {

    }

    private void setData() {


    }

    private void initData() {
        new DetailNetTask(){
            @Override
            public void onCallBack(Detail result) {
                mTextViewDui.setText("满370元免境内运费");
                mTextViewTitle.setText(result.getData().getEname());
                mTextViewZan.setText(result.getData().getLikes()+"");
                mTextViewNei.setText(result.getData().getEditorcomment().getComments());
                mTextViewLai.setText("该商品来自"+result.getData().getOrigin_name());
            }
        }.execute(NetConfig.ID_PATH);
        new DetailNetTask(){
            @Override
            public void onCallBack(Detail result) {
                mTextViewTitle2.setText(result.getData().getLabels().get(0));
                getmTextViewMoney.setText(result.getData().getCurrency_symbol()+result.getData().getSubentity().get(0).getPrice()+"元");
                Picasso.with(getActivity()).load(result.getData().getEntitypicv2().get(0).getFilename()).into(mImageView);
            }

        }.execute(NetConfig.ID_PATH);
    }

    private void initView(View view) {
        mTextViewDui = (TextView) view.findViewById(R.id.tv_goshoping_biaoqian);
        getmTextViewMoney = (TextView) view.findViewById(R.id.tv_goshoping_money);
        mTextViewZan = (TextView) view.findViewById(R.id.tv_goshoping_zan);
        mTextViewNei = (TextView) view.findViewById(R.id.tv_goshoping_neirong);
        mTextViewLai = (TextView) view.findViewById(R.id.tv_goshoping_laizi);
        mTextViewTitle2 = (TextView) view.findViewById(R.id.tv_goshoping_biaoqian2);
        mTextViewTitle = (TextView) view.findViewById(R.id.tv_goshoping_title);
        mImageView = (ImageView) view.findViewById(R.id.iv_goshoping_show);
    }
}
